package com.guet.niit.Admin.service;

import com.guet.niit.Admin.dao.UserDaolmpl;
import com.guet.niit.Admin.pojo.User;

import java.util.List;
import java.util.Scanner;

public class UserService {
    //用户添加
    public void userAdd(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要添加的用户ID:");
        Long id = scanner.nextLong();

        System.out.println("请输入用户名:");
        String username = scanner.next();

        System.out.println("请输入密码");
        String password = scanner.next();

        User user = new User(username,id,password);
        user.setId(id);
        user.setUsername(username);
        user.setPassword(password);

        UserDaolmpl ua = new UserDaolmpl();
        ua.userAdd(user);


    }

    //用户删除
    public void userDelete() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要删除的用户id:");
        Long id = scanner.nextLong();

        UserDaolmpl userDaolmpl = new UserDaolmpl();
        userDaolmpl.userDelete(id);
    }

    //用户更改
    public void userModify(){
        Scanner ms = new Scanner(System.in);
        System.out.println("请输入需要修改的用户id:");
        Long id = ms.nextLong();

        System.out.println("请输入用户名:");
        String username = ms.next();

        System.out.println("请输入密码:");
        String password = ms.next();

        User user = new User(username,id,password);
        user.setUsername(username);
        user.setId(id);
        user.setPassword(password);

        UserDaolmpl userDaolmpl = new UserDaolmpl();
        userDaolmpl.userModify(username,id,password);

        System.out.println("用户修改完成");
    }

    //用户查询
    public void userInquire(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入需要查询的id:");
        Long id =scanner.nextLong();
        UserDaolmpl userDaolmpl = new UserDaolmpl();
        List<User> userArrayList = userDaolmpl.userInquire();
        System.out.println(userArrayList);
    }

}
